﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FinalTestMachine.MES
{
    public class MESCommand
    {
        public static Dictionary<string, MESCommand> MESCommandDict = new Dictionary<string, MESCommand>();

        public MESCommand(string name, string header, string command)
        {
            Name = name;
            Header = header;
            Command = command;
            if (MESCommandDict.ContainsKey(header) == false)
            {
                MESCommandDict.Add(header, this);
            }
        }

        public static string Station => GetStationNameEventHandler?.Invoke();
        public string Name { get; set; }
        public string Header { get; set; }
        public string Command { get; }
        public string Data { get; set; }

        public MESResult Result { get; set; } = new MESResult();

        public static string End { get; set; }

        public static Func<string> GetStationNameEventHandler;

        public void SetData(string data)
        {
            Data = data;
        }

        public override string ToString()
        {
            return $"{Header};Command:{Command};Station:{Station};{Data};{End}";
        }
    }
}